<?php
namespace app\utils;
use App;
class Request extends \app\BaseObject{
	public function get($key=null){
		$data = App::$app->f3->get('GET');
		return empty($key) ? $data : (isset($data[$key]) ? $data[$key] : null);
	}
	public function post($key=null){
		$data = App::$app->f3->get('POST');
		return empty($key) ? $data : (isset($data[$key]) ? $data[$key] : null);
	}
	public function param($key){
		return App::$app->f3->get('PARAMS.'.$key);
	}

	public function to($route, $param=[], $only_param = true){
		if(!$only_param){
			$get = $this->get();
			$param = !empty($get) ? array_merge($get, $param) : $param;
		}
		return $route . '?' . http_build_query($param, '&');
	}
}